import request from '@/utils/request'

export const getUserChannelAPI = () => {
  return request.get('/v1_0/user/channels')
}

export const getArtListAPI = (id) => {
  return request.get('/v1_1/articles', {
    params: {
      channel_id: id, // 频道ID
      timestamp: Date.now(), // 时间戳
      with_top: 1
    }
  })
}

// 将文章设置为不感兴趣（形参 id 是文章的 id）
export const dislikeArticleAPI = id => {
  return request.post('/v1_0/article/dislikes', {
    target: id
  })
}

// 举报文章api
export const reportArticleAPI = (target, type) => {
  return request.post('/v1_0/article/reports', {
    target, // 文章的 Id
    type // 举报的类型
  })
}

// 获取所有频道数据
export const getAllChannelAPI = () => {
  return request.get('/v1_0/channels')
}

// 更新用户频道到列表数据的API
export const updateUSerChannelAPI = (channels) => {
  return request.put('/v1_0/user/channels', {
    channels
  })
}
